//
//  HeaderViewCollectionReusableView.m
//  PYWGetColor
//
//  Created by 杜文杰 on 2018/6/11.
//  Copyright © 2018年 dwj. All rights reserved.
//

#import "HeaderViewCollectionReusableView.h"

@implementation HeaderViewCollectionReusableView
- (void) btnAction:(UIButton *)btn
{
    if (self.searchBtnBlock) {
        self.searchBtnBlock();
    }
}
- (instancetype)initWithFrame:(CGRect)frame
{
    if (self = [super initWithFrame:frame]) {
        UIButton *topBtn = [[UIButton alloc]init];
        topBtn.backgroundColor = getColor(bgColor);
        [topBtn setTitleColor:getColor(textColor) forState:UIControlStateNormal];
        topBtn.titleLabel.font = DEF_FontSize_14;
        topBtn.titleLabel.textAlignment = NSTextAlignmentLeft;
        [topBtn setTitle:@"点此处搜索，快速找到您的服务类别" forState:UIControlStateNormal];
        [topBtn setImage:[UIImage imageNamed:@"ip"] forState:UIControlStateNormal];
        [topBtn setImageEdgeInsets:UIEdgeInsetsMake(0, -50 / WIDTH_6S_SCALE, 0, 0)];
        [topBtn setTitleEdgeInsets:UIEdgeInsetsMake(0, -40 / WIDTH_6S_SCALE, 0, 0)];
        [topBtn addTarget:self action:@selector(btnAction:) forControlEvents:UIControlEventTouchUpInside];
        [self addSubview:topBtn];
        __weak typeof(self)weakself = self;
        [topBtn mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(weakself.mas_top).offset(20 / HEIGHT_6S_SCALE);
            make.left.equalTo(weakself.mas_left).offset(20 / WIDTH_6S_SCALE);
            make.right.equalTo(weakself.mas_right).offset(-20 / WIDTH_6S_SCALE);
            make.height.mas_equalTo(36 / HEIGHT_6S_SCALE);
        }];
        topBtn.layer.cornerRadius = 18 / HEIGHT_6S_SCALE;
        topBtn.layer.masksToBounds = YES;
    }
    return self;
}
@end
